package hlhj.fhp.tvlib.adapter

import android.support.v4.app.Fragment
import android.support.v4.app.FragmentManager
import android.support.v4.app.FragmentPagerAdapter
import android.support.v4.view.PagerAdapter
import android.view.View
import android.view.ViewGroup
import hlhj.fhp.tvlib.fragment.HomeCastNew
import hlhj.fhp.tvlib.fragment.HomeLiveFgm
import hlhj.fhp.tvlib.fragment.HomeTvFgm
import kotlinx.android.synthetic.main.sample_video.*

/**
 * Created by Administrator on 2018\5\24 0024.
 */
class LivePagerAdp(var fm: FragmentManager, val datas:List<Fragment>) :FragmentPagerFlushAdapter(fm){
    override fun getItem(position: Int): Fragment {
        return datas[position]
    }

    override fun getCount(): Int {
        return datas.size
    }

    override fun destroyItem(container: ViewGroup, position: Int, `object`: Any) {
//        super.destroyItem(container, position, `object`)

    }

    override fun getPageTitle(position: Int): CharSequence? {
        val fragment = datas[position]
        if (fragment is HomeCastNew){
            return "广播"
        }else if (fragment is HomeLiveFgm){
            return "直播"
        }else if (fragment is HomeTvFgm){
            return "电视"
        }else{
            return ""
        }
    }
}